﻿<%@ Page Title="TFEB | Deck" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="TeamFoundation.EventBus.Default" %>
<asp:Content ContentPlaceHolderID="_coreContent" runat="server">
    <p class="intro">
    Welcome to Team Foundation Event Bus control deck. You can control all of the
    aspects of Team Foundation Event Bus from this website.</p>
<h2>
    Installation
</h2>

<asp:Panel ID="_installPanel" runat="server">
    <p style="color:red">
        TFEB has not yet been installed or configured and will
        not function until it has been.
    </p>
    <p>
        <asp:HyperLink ID="_installLink" NavigateUrl="Install.aspx" runat="server">Install Team Foundation Event Bus</asp:HyperLink>.
    </p>
</asp:Panel>

<asp:Panel ID="_uninstallPanel" runat="server">
    <p>
        TFEB is installed and configured.
    </p>
    <table>
        <tr>
            <td>Client Access URL:</td>
            <td><asp:HyperLink runat="server" ID="_idAccessUrl" /></td>
        </tr>
        <tr>
            <td>Team Foundation Server:</td>
            <td><asp:HyperLink runat="server" ID="_idTeamServer" /></td>
        </tr>
        <tr>
            <td>Database Server:</td>
            <td><asp:Label runat="server" ID="_idDatabaseServer" /></td>
        </tr>
        <tr>
            <td>Database Name:</td>
            <td><asp:Label runat="server" ID="_idDatabaseName" /></td>
        </tr>
    </table>
    <p>
        <asp:HyperLink ID="_uninstallLink" NavigateUrl="Uninstall.aspx" runat="server">Uninstall Team Foundation Event Bus</asp:HyperLink>.
    </p>
</asp:Panel>

<asp:Panel ID="_subscriptionsPanel" runat="server">
    <h2>TFS Subscriptions</h2>

    <table>
        <thead>
            <tr>
                <td>Subscription</td>
                <td>Event Name</td>
            </tr>
        </thead>
        
        <tbody>
            <asp:Repeater ID="_subscriptions" runat="server">
                <ItemTemplate>
                    <tr>
                        <td><a style="margin-right: 10px;" href="Action.ashx?type=SubscribeAction&event=<%# DataBinder.Eval(Container.DataItem, "EventName") %>&to=<%# DataBinder.Eval(Container.DataItem, "NextAction") %>&id=<%# DataBinder.Eval(Container.DataItem, "Id") %>"><%# DataBinder.Eval(Container.DataItem, "NextAction") %></a></td>
                        <td><%# DataBinder.Eval(Container.DataItem, "EventName") %></td>
                    </tr>
                </ItemTemplate>

                <FooterTemplate>
                </FooterTemplate>
            </asp:Repeater>
        </tbody>
        <tfoot>
            <tr>
                <td><a href="Action.ashx?type=SubscribeAction&to=Subscribe">Subscribe</a></td>
                <td><em>All</em></td>
            </tr>
            <tr>
                <td><a href="Action.ashx?type=SubscribeAction&to=Unsubscribe">Unsubscribe</a></td>
                <td><em>All</em></td>
            </tr>
            <tr>
                <td><asp:LinkButton ID="_addButton" Text="Subscribe" runat="server" OnClick="_addButton_Click" /></td>
                <td><asp:TextBox ID="_addTextBox" Text="" runat="server"/></td>
            </tr>
        </tfoot>
    </table>
</asp:Panel>

<asp:Panel ID="_queuesPanel" runat="server">
    <h2>TFEB Subscriptions</h2>
    <asp:DetailsView ID="_queueInsertView" runat="server" 
        AutoGenerateInsertButton="True" AutoGenerateRows="False" Caption="New Item" 
        DataSourceID="_queuesLinqDataSourceInsert" DefaultMode="Insert" 
        oniteminserted="_queueInsertView_ItemInserted" Width="100%">
        <Fields>
            <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
            <asp:BoundField DataField="MessageQueue" HeaderText="MessageQueue" 
                SortExpression="MessageQueue" />
            <asp:BoundField DataField="Filter" HeaderText="Filter" 
                SortExpression="Filter" />
            <asp:BoundField DataField="Id" HeaderText="Id" ReadOnly="True" 
                SortExpression="Id" Visible="False" />
        </Fields>
    </asp:DetailsView>
    <asp:GridView ID="_queuesGridView" runat="server" AutoGenerateColumns="False" 
        AllowSorting="True" DataSourceID="_queuesLinqDataSource" 
        AutoGenerateDeleteButton="True" AutoGenerateEditButton="True" 
        Caption="Current Subscriptions" DataKeyNames="Id" 
        EnableSortingAndPagingCallbacks="True" Width="100%">
        <Columns>
            <asp:BoundField HeaderText="Name" DataField="Name" 
                SortExpression="Name" ReadOnly="True" />
            <asp:BoundField HeaderText="MessageQueue" DataField="MessageQueue" 
                SortExpression="MessageQueue" />
            <asp:BoundField DataField="Filter" HeaderText="Filter" 
                SortExpression="Filter" />
            <asp:BoundField DataField="Id" HeaderText="Id" InsertVisible="False" 
                ReadOnly="True" SortExpression="Id" Visible="False" />
        </Columns>
        <EmptyDataTemplate>
            No TFEB Subscriptions have been defined.
        </EmptyDataTemplate>
    </asp:GridView>
    <asp:LinqDataSource ID="_queuesLinqDataSource" runat="server" 
        ContextTypeName="TeamFoundation.EventBus.Model.Database" 
        EnableDelete="True" EnableUpdate="True" 
        Select="new (Name, MessageQueue, Filter, Id)" TableName="SubscriptionSet">
    </asp:LinqDataSource>
    <asp:LinqDataSource ID="_queuesLinqDataSourceInsert" runat="server" 
        ContextTypeName="TeamFoundation.EventBus.Model.Database" EnableInsert="True" 
        Select="new (Name, MessageQueue, Filter, Id)" TableName="SubscriptionSet">
    </asp:LinqDataSource>
</asp:Panel>


</asp:Content>
